<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/24
 * Time: 14:52
 */
namespace app\web\controller;
use cmf\controller\HomeBaseController;
use app\portal\model\LogisticsModel;
use think\Db;
class LogisticsController extends HomeBaseController
{

    /**
     * 获取物流信息
     */
    public function getLogisticsInfo(){
        $param = $this->request->param();
        $LogisticsModel = new LogisticsModel();
        $condition['order_id'] = $param['order_id'];
        $LogisticsInfo = $LogisticsModel->where($condition)->order(['start_time' => 'asc'])->select();
        if (count($LogisticsInfo) == 0){
            return $this->json('1007','暂无该货单在途信息，请重新确认订单号或稍后再试~');
        }else{
            $LogisticsInfoList = array();
            foreach ($LogisticsInfo as $k => $val){
                $LogisticsInfoList[$k]['time'] = date('H:i:s',strtotime($val['start_time']));
                $LogisticsInfoList[$k]['day'] = date('Y-m-d',strtotime($val['start_time']));
                $LogisticsInfoList[$k]['distance'] = $val['distance'];
                if ($param['languageType'] == 1){
                    $LogisticsInfoList[$k]['place'] = $val['place'];
                    $LogisticsInfoList[$k]['remark'] = $val['remark'];
                }else{
                    $LogisticsInfoList[$k]['place'] = $val['placeEnglish'];
                    $LogisticsInfoList[$k]['remark'] = $val['remarkEnglish'];
                }
            }
            return $this->json('0','请求成功',$LogisticsInfoList);
        }
    }


}